// JavaScript Document
// This function simplify the coding of puting embedded video on web pages.
// It supports 
// 0 : YouTube
// 1:  Tudou
// 2:  YouKu
// 3:  KU6
// 4:  Google
//  For comments and bug reports, please write to me at hktintat@gmail.com.
function OpenNetVideo(iMode,strCode,iWidth,iHeight,sColor1,sColor2,iStart) {
   var param1, param2 ;
   var cColor1, cColor2 ;
   var nWidth, nHeight ;
   var strHtml = '' ;
   if ((iStart == undefined) || (iStart == null) || (iStart == '')) {
      iStart = 0 ;
   }
   if (iDefWidth == undefined) { iDefWidth =400 ;}
   if (iDefHeight == undefined) { iDefHeight =350 ;}
   // height of control panel
   if (iWidth == null) 
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight ;
     }
   else if ((iWidth == 0) && (iHeight == 0)) 
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight ;
     }
   else if (iWidth >= 100 && ((iHeight == null) || (iHeight == '') || (iHeight <= 0)))
     {
	   nWidth = iWidth ;
	   nHeight = ((iWidth / 4) * 3)  ;
	 }
   else if (iWidth >=100 && iHeight >=100) 
     {
	   nWidth = iWidth ;
	   nHeight = iHeight ;
	 }
   else
     {
	   nWidth = iDefWidth ;
	   nHeight = iDefHeight  ;
	 }
   
   if ((sColor1 == undefined) || (sColor1 == null) || (sColor1 == ''))
   {
	  cColor1 = "0x656565" ;
   }
   else
   {
      cColor1 = sColor1 ;
   }
   if ((sColor2 == undefined) || (sColor2 == null) || (sColor2 == ''))
   {
	  cColor2 = "0xeeeeee" ;
   }
   else
   {
      cColor2 = sColor2 ;
   }
   switch (iMode)
   {
        case 0 : //YouTube
		  strHtml = '<iframe class="youtube-player" type="text/html" width="' + nWidth + '" height="' + nHeight + '" src="http://www.youtube.com/embed/' + strCode + '" frameborder="0"></iframe>' ;
		  break 
	   case 1 : //Tudou
	      strHtml = '<embed src="http://www.tudou.com/v/' + strCode + '/v.swf" width="' + nWidth + '" height="' + nHeight + 
                    '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" quality="high" align="middle" wmode="opaque" ></embed>' ;
		  break
        case 2 : //YouKu
	      strHtml = '<embed src="http://player.youku.com/player.php/sid/' + strCode +  '/v.swf" width="' + nWidth + '" height="' + nHeight + 
                    '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" quality="high" align="middle" wmode="opaque" ></embed>' ;
		  break
	    case 3 : //KU6
	      strHtml = '<embed src="http://player.ku6.com/refer/' + strCode + '/v.swf" width="' + nWidth + '" height="' + nHeight + 
                    '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" quality="high" align="middle" wmode="opaque" ></embed>' ;
		  break
	    case 4 : //Google
          strHtml = '<embed id=VideoPlayback src=http://video.google.com/googleplayer.swf?docid=' + url + '&hl=en&fs=true style=width:' + nWidth + 'px;height:' + nHeight + 'px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed>' ;
		  break 
        case 100 : //YouTube
          strHtml = '<object width="' + nWidth + '" height="' + nHeight + '">' + 
                    '<param name="movie" value="http://www.youtube.com/v/' + strCode + '=en_US&fs=1&rel=0&color1=' + 
					cColor1 + '&color2=' + cColor2 + '&hd=0"></param>' +
	                '<param name="allowFullScreen" value="true"></param>' +
                    '<param name="allowscriptaccess" value="always"></param>' +
                    '<embed src="http://www.youtube.com/v/' + strCode +'&hl=en_US&fs=1&rel=0&color1=' + 
					cColor1 + '&color2=' + cColor2 + 
					'&hd=0&start=' + iStart + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + 
					nWidth + '" height="' +nHeight + '"></embed>' + '</object>' ;
	      break
    }
 document.write(strHtml) ;
}